'''
数据可视化以及数据分布分析
'''
import json
import cv2
import os
import xml
import xml.etree.cElementTree as ET

try:
    import xml.etree.cElementTree as ET
except:
    import xml.etree.ElementTree as ET


def xml_to_dic(xml_str):
    # xml文件转字典
    msg = {}
    root_elem = ET.fromstring(xml_str)
    if root_elem.tag == 'xml':
        for ch in root_elem:
            msg[ch.tag] = ch.text


def show_image(image_path,label_path):
    for name in os.listdir(image_path):
        image = cv2.imread(os.path.join(image_path,name))
        label = tree = ET.ElementTree(file=os.path.join(label_path,name.replace('bmp','xml')))
        root = tree.getroot()
        node_filename = root[0]
        print("文件名：", node_filename.text)


if __name__ == '__main__':
    show_image(image_path='../data/train/image',label_path='../data/train/box')